#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define pd(n) printf("%d", (n))
using namespace std;
void solve()
{
	int a[3] = { 1,1,1 };
	int c = 0;
	int q = 20190324 - 3;
	while (q--)
	{
		c = (a[0] % 10000 + a[1] % 10000 + a[2] % 10000) % 10000;
		a[0] = a[1];
		a[1] = a[2];
		a[2] = c;
	}

	q = 4;
	int ans[4] = { 0,0,0,0 };
	while (q--)
	{
		ans[q] = c % 10;
		c /= 10;
	}
	for (int i = 0; i < 4; i++) pd(ans[i]);
}

int main()
{
	int T = 1;
	//sd(T);
	while (T--)
	{
		solve();
	}
	return 0;
}